package com.tencent.sr.iris.basic.saas.restapi;

import com.tencent.sr.iris.basic.saas.interfaces.request.export.ExportRequest;
import com.tencent.sr.iris.basic.saas.interfaces.response.export.ExportBusinessTypeResponse;
import com.tencent.sr.iris.basic.saas.interfaces.response.export.ExportResponse;
import com.tencent.sr.iris.basic.saas.service.export.ExportService;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@Slf4j
@Api("导出")
@RestController
@RequestMapping("/iris/basic/saas/v1/export")
public class ExportController {

    @Resource
    private ExportService exportService;

    @ApiOperation("导出")
    @PostMapping("commonExport")
    HttpResult<ExportResponse> commonExport(@Valid @RequestBody ExportRequest request) {
        ExportResponse response = exportService.commonRequest(request.getExportType(), request.getReqJsonStr());
        return HttpResult.succ(response);
    }

    @ApiOperation("导出类型列表")
    @PostMapping("businessTypeList")
    HttpResult<List<ExportBusinessTypeResponse>> businessTypeList() {
        List<ExportBusinessTypeResponse> businessTypeList = exportService.businessTypeList();
        return HttpResult.succ(businessTypeList);
    }
}
